
import java.awt.Dimension;
import java.awt.Toolkit;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.swing.ComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JTextField;

public class FrameStart extends javax.swing.JFrame 
{
    private Query query = new Query();
    private Manager manager = new Manager();
    private TreeMap<String, JComboBox> combo_box_map = new TreeMap();
    public FrameStart() 
    {
        initComponents();
        createTreeMapComboBox();
        lockComboBoxBySelectedItem();
        fillSizeComboBox();
        fillTypeComboBox();
        fillLanguageComboBox();
    }
    public void initFrame()
    {
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        Dimension screenSize = toolkit.getScreenSize(); 
        Dimension framesize = this.getSize();
        int x = (int) ( screenSize.getWidth() - framesize.getWidth() ) / 2;
        int y = (int) ( screenSize.getHeight() - framesize.getHeight() ) / 2;
        setLocation( x, y );
        setResizable(false);
        setVisible( true );
    }
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        button_group_select_file = new javax.swing.ButtonGroup();
        button_group_chart = new javax.swing.ButtonGroup();
        label_select_file = new javax.swing.JLabel();
        radio_button_data_base = new javax.swing.JRadioButton();
        radio_button_directory = new javax.swing.JRadioButton();
        text_field_directory = new javax.swing.JTextField();
        button_choose_directory = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        label_chart = new javax.swing.JLabel();
        button_write_data = new javax.swing.JButton();
        button_create_chart = new javax.swing.JButton();
        label_files_count = new javax.swing.JLabel();
        text_field_files_count = new javax.swing.JTextField();
        label_files_size = new javax.swing.JLabel();
        text_field_files_size = new javax.swing.JTextField();
        combo_box_alphabet = new javax.swing.JComboBox();
        label_alphabet = new javax.swing.JLabel();
        label_count_letters = new javax.swing.JLabel();
        text_field_count_letters = new javax.swing.JTextField();
        radio_button_type_random = new javax.swing.JRadioButton();
        radio_button_type_sequence = new javax.swing.JRadioButton();
        label_charts_title = new javax.swing.JLabel();
        text_field_charts_title = new javax.swing.JTextField();
        label_absciss_data = new javax.swing.JLabel();
        combo_box_absciss_data = new javax.swing.JComboBox();
        label_ordinate_data = new javax.swing.JLabel();
        combo_box_ordinate_data = new javax.swing.JComboBox();
        label_parameters = new javax.swing.JLabel();
        label_type = new javax.swing.JLabel();
        combo_box_type = new javax.swing.JComboBox();
        label_size = new javax.swing.JLabel();
        label_language = new javax.swing.JLabel();
        combo_box_size = new javax.swing.JComboBox();
        radio_button_file = new javax.swing.JRadioButton();
        radio_button_crypto_file = new javax.swing.JRadioButton();
        label_archive_level = new javax.swing.JLabel();
        combo_box_archive_level = new javax.swing.JComboBox();
        label_encrypt_mode = new javax.swing.JLabel();
        combo_box_encrypt_mode = new javax.swing.JComboBox();
        combo_box_language = new javax.swing.JComboBox();
        jButton1 = new javax.swing.JButton();
        label_compressor = new javax.swing.JLabel();
        combo_box_compressor = new javax.swing.JComboBox();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        label_select_file.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_select_file.setText("Select file from:");

        button_group_select_file.add(radio_button_data_base);
        radio_button_data_base.setSelected(true);
        radio_button_data_base.setText("DataBase");
        radio_button_data_base.setFocusable(false);
        radio_button_data_base.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radio_button_data_baseActionPerformed(evt);
            }
        });

        button_group_select_file.add(radio_button_directory);
        radio_button_directory.setText("Directory");
        radio_button_directory.setFocusable(false);
        radio_button_directory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radio_button_directoryActionPerformed(evt);
            }
        });

        text_field_directory.setEditable(false);
        text_field_directory.setEnabled(false);

        button_choose_directory.setText("...");
        button_choose_directory.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_choose_directoryActionPerformed(evt);
            }
        });

        jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);

        label_chart.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_chart.setText("Chart:");

        button_write_data.setText("Write Data");
        button_write_data.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_write_dataActionPerformed(evt);
            }
        });

        button_create_chart.setText("Create Chart");
        button_create_chart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                button_create_chartActionPerformed(evt);
            }
        });

        label_files_count.setText("files count: ");

        text_field_files_count.setEditable(false);
        text_field_files_count.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        label_files_size.setText("files size:");

        text_field_files_size.setEditable(false);
        text_field_files_size.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        combo_box_alphabet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "English", "Russian" }));
        combo_box_alphabet.setAutoscrolls(true);
        combo_box_alphabet.setEnabled(false);
        combo_box_alphabet.setFocusable(false);
        combo_box_alphabet.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_box_alphabetActionPerformed(evt);
            }
        });

        label_alphabet.setText("alphabet:");

        label_count_letters.setText("count letters:");

        text_field_count_letters.setEditable(false);
        text_field_count_letters.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        button_group_select_file.add(radio_button_type_random);
        radio_button_type_random.setText("Random");
        radio_button_type_random.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radio_button_type_randomActionPerformed(evt);
            }
        });

        button_group_select_file.add(radio_button_type_sequence);
        radio_button_type_sequence.setText("Sequence");
        radio_button_type_sequence.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radio_button_type_sequenceActionPerformed(evt);
            }
        });

        label_charts_title.setText("Charts Title: ");

        label_absciss_data.setText("Absciss Data: ");

        combo_box_absciss_data.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "size", "type", "language", "encrypt_mode", "archive_level" }));
        combo_box_absciss_data.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                combo_box_absciss_dataActionPerformed(evt);
            }
        });

        label_ordinate_data.setText("Ordinate Data: ");

        combo_box_ordinate_data.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ratio", "time", "processor_memory" }));

        label_parameters.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        label_parameters.setText("Parameters: ");

        label_type.setText("Type: ");

        label_size.setText("Size: ");

        label_language.setText("Language: ");

        button_group_chart.add(radio_button_file);
        radio_button_file.setSelected(true);
        radio_button_file.setText("file");
        radio_button_file.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radio_button_fileActionPerformed(evt);
            }
        });

        button_group_chart.add(radio_button_crypto_file);
        radio_button_crypto_file.setText("crypto_file");
        radio_button_crypto_file.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                radio_button_crypto_fileActionPerformed(evt);
            }
        });

        label_archive_level.setText("Archive Level: ");

        combo_box_archive_level.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "max", "medium", "min" }));

        label_encrypt_mode.setText("Encrypt Mode: ");

        combo_box_encrypt_mode.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ECB", "CBC", "CFB", "OFB", "PCBC" }));

        jButton1.setText("Clear Table");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        label_compressor.setText("Compressor: ");

        combo_box_compressor.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "rar", "zip", "bzip2", "7zip", "lzma" }));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(radio_button_data_base, javax.swing.GroupLayout.PREFERRED_SIZE, 317, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(11, 11, 11))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(radio_button_type_random)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(31, 31, 31)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(label_alphabet)
                                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                                .addComponent(label_files_size, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(label_files_count, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .addComponent(label_count_letters, javax.swing.GroupLayout.Alignment.LEADING))))
                                    .addComponent(radio_button_directory))
                                .addGap(26, 26, 26)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(radio_button_type_sequence)
                                        .addGap(93, 93, 93))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(text_field_count_letters, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(text_field_files_size, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(text_field_files_count, javax.swing.GroupLayout.DEFAULT_SIZE, 186, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(combo_box_alphabet, 0, 186, Short.MAX_VALUE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGroup(layout.createSequentialGroup()
                                                .addComponent(text_field_directory, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
                                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                .addComponent(button_choose_directory, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(label_select_file, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(97, 97, 97)))
                        .addGap(18, 18, 18))
                    .addComponent(button_write_data, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 4, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(7, 7, 7)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(label_charts_title)
                            .addComponent(radio_button_file))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(text_field_charts_title, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                            .addComponent(combo_box_absciss_data, javax.swing.GroupLayout.Alignment.TRAILING, 0, 211, Short.MAX_VALUE)
                            .addComponent(combo_box_ordinate_data, javax.swing.GroupLayout.Alignment.TRAILING, 0, 211, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 4, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(label_ordinate_data)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 215, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(label_absciss_data, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 207, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(label_language)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 242, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_type)
                        .addGap(276, 276, 276))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_size)
                        .addGap(279, 279, 279))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_compressor)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 228, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_encrypt_mode)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 219, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_archive_level)
                        .addGap(222, 222, 222))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(116, 116, 116)
                        .addComponent(radio_button_crypto_file)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 109, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(label_chart, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
                    .addComponent(label_parameters, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 314, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(104, 104, 104)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(combo_box_archive_level, javax.swing.GroupLayout.Alignment.TRAILING, 0, 210, Short.MAX_VALUE)
                            .addComponent(combo_box_encrypt_mode, javax.swing.GroupLayout.Alignment.TRAILING, 0, 210, Short.MAX_VALUE)
                            .addComponent(combo_box_compressor, javax.swing.GroupLayout.Alignment.TRAILING, 0, 210, Short.MAX_VALUE)
                            .addComponent(combo_box_size, javax.swing.GroupLayout.Alignment.TRAILING, 0, 210, Short.MAX_VALUE)
                            .addComponent(combo_box_type, javax.swing.GroupLayout.Alignment.TRAILING, 0, 210, Short.MAX_VALUE)
                            .addComponent(combo_box_language, 0, 210, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(104, 104, 104)
                        .addComponent(button_create_chart, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 71, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(22, 22, 22))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(label_chart, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(radio_button_file)
                            .addComponent(radio_button_crypto_file))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(label_charts_title)
                            .addComponent(text_field_charts_title, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_absciss_data)
                            .addComponent(combo_box_absciss_data, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_ordinate_data)
                            .addComponent(combo_box_ordinate_data, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(21, 21, 21)
                        .addComponent(label_parameters)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_language)
                            .addComponent(combo_box_language, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_type)
                            .addComponent(combo_box_type, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_size)
                            .addComponent(combo_box_size, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_compressor)
                            .addComponent(combo_box_compressor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_encrypt_mode)
                            .addComponent(combo_box_encrypt_mode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_archive_level)
                            .addComponent(combo_box_archive_level, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(button_create_chart, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addComponent(label_select_file, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(8, 8, 8)
                        .addComponent(radio_button_data_base, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(radio_button_type_random)
                            .addComponent(radio_button_type_sequence))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_alphabet)
                            .addComponent(combo_box_alphabet, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_files_count)
                            .addComponent(text_field_files_count, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_files_size, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(text_field_files_size, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(label_count_letters)
                            .addComponent(text_field_count_letters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(radio_button_directory, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(button_choose_directory)
                            .addComponent(text_field_directory, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(button_write_data, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void radio_button_data_baseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio_button_data_baseActionPerformed
    text_field_directory.setText("");
    text_field_directory.setEditable(false);
    setLockRandomRepositoryField(false);
}//GEN-LAST:event_radio_button_data_baseActionPerformed

private void radio_button_directoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio_button_directoryActionPerformed
    text_field_directory.setEditable(true);
    setLockRandomRepositoryField(false);
}//GEN-LAST:event_radio_button_directoryActionPerformed

private void button_choose_directoryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_choose_directoryActionPerformed
    if(radio_button_directory.isSelected())
    { 
        FrameDirectoryChooser frame_directory_dialog = new FrameDirectoryChooser(this);
        frame_directory_dialog.initFrame();
    }
}//GEN-LAST:event_button_choose_directoryActionPerformed

private void button_write_dataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_write_dataActionPerformed
    if(radio_button_data_base.isSelected())
        manager.WriteDataForFileFromDataBase();
    if(radio_button_directory.isSelected())
        manager.WriteDataForFileFromDirectory(text_field_directory.getText());
    if(radio_button_type_random.isSelected())
        manager.WriteDataForRandomFileFromGenerator(radio_button_type_random.getText(),
                                                     ParseInt(text_field_files_count.getText()), 
                                                     ParseInt(text_field_files_size.getText()), 
                                                     getAlphabetsLanguage());
    if(radio_button_type_sequence.isSelected())
        manager.WriteDataForSequenceFileFromGenerator(radio_button_type_sequence.getText(),
                                                     ParseInt(text_field_files_count.getText()), 
                                                     ParseInt(text_field_files_size.getText()), 
                                                     getAlphabetsLanguage(),
                                                     ParseInt(text_field_count_letters.getText()));
}//GEN-LAST:event_button_write_dataActionPerformed

private void radio_button_type_randomActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio_button_type_randomActionPerformed
    text_field_directory.setText("");
    text_field_directory.setEditable(false);
    setLockRandomRepositoryField(true);
    text_field_count_letters.setText("" + setLettersCount());
    text_field_count_letters.setEditable(false);
}//GEN-LAST:event_radio_button_type_randomActionPerformed

private void radio_button_type_sequenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio_button_type_sequenceActionPerformed
    setLockRandomRepositoryField(true);
}//GEN-LAST:event_radio_button_type_sequenceActionPerformed

private void combo_box_alphabetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_box_alphabetActionPerformed
    text_field_count_letters.setText("" + setLettersCount());
    text_field_count_letters.setEditable(false);
}//GEN-LAST:event_combo_box_alphabetActionPerformed

private void button_create_chartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_button_create_chartActionPerformed
    String chart_title = text_field_charts_title.getText();
    String absciss_label = getSelectedItemFromAbscissDataComboBox();
    String ordinate_label = getSelectedItemFromOrdinateDataComboBox();
    Long size = new Long(Integer.parseInt(getSelectedItemFromSizeComboBox()));
    String type = getSelectedItemFromTypeComboBox();
    String language = getSelectedItemFromLanguageComboBox();
    String compressor = getSelectedItemFromCompressorComboBox();
    String archive_level = getSelectedItemFromArchiveLevelComboBox();
    String encrypt_mode = getSelectedItemFromEncryptModeComboBox();
    FrameChart frame_chart = new FrameChart(chart_title, absciss_label, ordinate_label);
    if(radio_button_file.isSelected())
        manager.createChartForFile(frame_chart, absciss_label, ordinate_label, size, type, language, archive_level);
    if(radio_button_crypto_file.isSelected())
        manager.createChartForCryptoFile(frame_chart, absciss_label, ordinate_label, size, type, language, compressor, encrypt_mode);
//GEN-LAST:event_button_create_chartActionPerformed
}                                                   

private void radio_button_fileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio_button_fileActionPerformed
    combo_box_encrypt_mode.setEnabled(false);
    combo_box_archive_level.setEnabled(true);
    combo_box_absciss_data.removeItem("encrypt_mode");
    combo_box_absciss_data.removeItem("compressor");
    if(!isFoundElements("archive_level"))
            combo_box_absciss_data.addItem("archive_level");
}//GEN-LAST:event_radio_button_fileActionPerformed

private void radio_button_crypto_fileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radio_button_crypto_fileActionPerformed
    combo_box_encrypt_mode.setEnabled(true);
    combo_box_compressor.setEnabled(true);
    combo_box_archive_level.setSelectedItem("medium");
    combo_box_archive_level.setEnabled(false);
    combo_box_absciss_data.removeItem("archive_level");
    if(!isFoundElements("encrypt_mode"))
            combo_box_absciss_data.addItem("encrypt_mode");
    if(!isFoundElements("compressor"))
            combo_box_absciss_data.addItem("compressor");
}//GEN-LAST:event_radio_button_crypto_fileActionPerformed

private void combo_box_absciss_dataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_combo_box_absciss_dataActionPerformed
    lockComboBoxBySelectedItem();
    
}//GEN-LAST:event_combo_box_absciss_dataActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    query.clearTable("TArchiveFile");
    query.clearTable("TCryptoFile");
    query.clearTable("TArchiveCryptoFile");
}//GEN-LAST:event_jButton1ActionPerformed

    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                new StartFrame().setVisible(true);
//            }
//        });
//    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton button_choose_directory;
    private javax.swing.JButton button_create_chart;
    private javax.swing.ButtonGroup button_group_chart;
    private javax.swing.ButtonGroup button_group_select_file;
    private javax.swing.JButton button_write_data;
    private javax.swing.JComboBox combo_box_absciss_data;
    private javax.swing.JComboBox combo_box_alphabet;
    private javax.swing.JComboBox combo_box_archive_level;
    private javax.swing.JComboBox combo_box_compressor;
    private javax.swing.JComboBox combo_box_encrypt_mode;
    private javax.swing.JComboBox combo_box_language;
    private javax.swing.JComboBox combo_box_ordinate_data;
    private javax.swing.JComboBox combo_box_size;
    private javax.swing.JComboBox combo_box_type;
    private javax.swing.JButton jButton1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JLabel label_absciss_data;
    private javax.swing.JLabel label_alphabet;
    private javax.swing.JLabel label_archive_level;
    private javax.swing.JLabel label_chart;
    private javax.swing.JLabel label_charts_title;
    private javax.swing.JLabel label_compressor;
    private javax.swing.JLabel label_count_letters;
    private javax.swing.JLabel label_encrypt_mode;
    private javax.swing.JLabel label_files_count;
    private javax.swing.JLabel label_files_size;
    private javax.swing.JLabel label_language;
    private javax.swing.JLabel label_ordinate_data;
    private javax.swing.JLabel label_parameters;
    private javax.swing.JLabel label_select_file;
    private javax.swing.JLabel label_size;
    private javax.swing.JLabel label_type;
    private javax.swing.JRadioButton radio_button_crypto_file;
    private javax.swing.JRadioButton radio_button_data_base;
    private javax.swing.JRadioButton radio_button_directory;
    private javax.swing.JRadioButton radio_button_file;
    private javax.swing.JRadioButton radio_button_type_random;
    private javax.swing.JRadioButton radio_button_type_sequence;
    private javax.swing.JTextField text_field_charts_title;
    private javax.swing.JTextField text_field_count_letters;
    private javax.swing.JTextField text_field_directory;
    private javax.swing.JTextField text_field_files_count;
    private javax.swing.JTextField text_field_files_size;
    // End of variables declaration//GEN-END:variables

    private void setLockRandomRepositoryField(boolean lock)
    {
        text_field_files_size.setText("");
        text_field_files_size.setFocusable(lock);
        text_field_files_size.setEditable(lock);
        text_field_files_count.setText("");
        text_field_files_count.setFocusable(lock);
        text_field_files_count.setEditable(lock); 
        combo_box_alphabet.setEnabled(lock);
        text_field_count_letters.setText("");
        text_field_count_letters.setEditable(lock);
    }
    public JTextField getDirectoryTextField()
    {
        return text_field_directory;
    }
    private int ParseInt(String string)
    {
        int number = 0;
        try 
        {
            number = Integer. parseInt(string);
            return number;
        }
        catch(NumberFormatException ex) 
        {
            System.out.print("\n Can not parse number: " + ex);
            return number;
        }
    }
    private String getAlphabetsLanguage()
    {
        return combo_box_alphabet.getSelectedItem().toString();
    }
    private int setLettersCount()
    {
        int letters_count = 0;
        String language = getAlphabetsLanguage();
        if(language.equals("English"))
            letters_count = 85; // 33 + 26 + 26 = 85; 33 - number and other symbols
        if(language.equals("Russian"))
            letters_count = 97; // 33 + 32 + 32 = 97
        return letters_count;
    }
   private void fillSizeComboBox()
   {
       List different_sizes_list = query.getElementsFromTFileForColumn("size");
       Iterator sizes_iterator = different_sizes_list.iterator();
       while(sizes_iterator.hasNext())
       {
            combo_box_size.addItem(sizes_iterator.next().toString());
       }
   }
   private void fillTypeComboBox()
   {
        List different_types_list = query.getElementsFromTFileForColumn("type");
        Iterator types_iterator = different_types_list.iterator();
        while(types_iterator.hasNext())
        {
            combo_box_type.addItem(types_iterator.next());
        }      
   }
   private void fillLanguageComboBox()
   {
        List different_languages_list = query.getElementsFromTFileForColumn("language");
        Iterator languages_iterator = different_languages_list.iterator();
        while(languages_iterator.hasNext())
        {
            combo_box_language.addItem(languages_iterator.next());
        }      
   }
   private void createTreeMapComboBox()
   {
        combo_box_map.put("size", combo_box_size);
        combo_box_map.put("type", combo_box_type);
        combo_box_map.put("language", combo_box_language);
        combo_box_map.put("encrypt_mode", combo_box_encrypt_mode);
        combo_box_map.put("archive_level", combo_box_archive_level);
        combo_box_map.put("compressor", combo_box_compressor);
   }
   private void lockComboBoxBySelectedItem()
   {      
       String selected_item = (String)combo_box_absciss_data.getSelectedItem();
       Iterator combo_box_map_iterator = combo_box_map.entrySet().iterator();
        while(combo_box_map_iterator.hasNext())
        {
            Map.Entry<String, JComboBox> entry = (Map.Entry)combo_box_map_iterator.next();
            if(entry.getKey().equals(selected_item))
                entry.getValue().setEnabled(false);
            else 
                entry.getValue().setEnabled(true);
        }
       lockComboBoxByFilesType();
   }   
   private void lockComboBoxByFilesType()
   {
        if(radio_button_file.isSelected())
        {
            combo_box_encrypt_mode.setEnabled(false);
            combo_box_compressor.setEnabled(false);
        }
        if(radio_button_crypto_file.isSelected())
            combo_box_archive_level.setEnabled(false);
   }
   private boolean isFoundElements(String elements)
   {
        ComboBoxModel model = combo_box_absciss_data.getModel();
        boolean isFoundElements = false;
        int size_combo_box = model.getSize();
        for(int i = 0; i < size_combo_box; i++)
        {
            if(model.getElementAt(i).toString().equals(elements))
                isFoundElements = true;
        }   
        return isFoundElements;
   }
   private String getSelectedItemFromAbscissDataComboBox()
   {
        return combo_box_absciss_data.getSelectedItem().toString();
   }
   private String getSelectedItemFromOrdinateDataComboBox()
   {
        return combo_box_ordinate_data.getSelectedItem().toString();
   }
   private String getSelectedItemFromLanguageComboBox()
   {
        return combo_box_language.getSelectedItem().toString();
   }
   private String getSelectedItemFromTypeComboBox()
   {
        return combo_box_type.getSelectedItem().toString();
   }
   private String getSelectedItemFromSizeComboBox()
   {
        return combo_box_size.getSelectedItem().toString();
   }
   private String getSelectedItemFromCompressorComboBox()
   {
        return combo_box_compressor.getSelectedItem().toString();
   }
   private String getSelectedItemFromEncryptModeComboBox()
   {
        return combo_box_encrypt_mode.getSelectedItem().toString();
   }
   private String getSelectedItemFromArchiveLevelComboBox()
   {
        return combo_box_archive_level.getSelectedItem().toString();
   }
}
